@extends('layouts.app', ['activePage' => 'apply', 'titlePage' => __('入驻审核')])

@section('content')
  <div class="content">
    <div class="container-fluid">
      <div class="row">
        <div class="col-md-12">
          <div class="card">
            <div class="card-header card-header-primary">
              <h4 class="card-title ">{{ __('申请列表') }}</h4>
              <p class="card-category"> {{ __('审核匠人入驻申请') }}</p>
            </div>
            <div class="card-body">
              @if (session('status'))
                <div class="row">
                  <div class="col-sm-12">
                    <div class="alert alert-success">
                      <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <i class="material-icons">close</i>
                      </button>
                      <span>{{ session('status') }}</span>
                    </div>
                  </div>
                </div>
              @endif
              <div class="table-responsive">
                <table class="table">
                  <thead class="text-primary text-center">
                  <th>
                    编号
                  </th>
                  <th>
                    用户名
                  </th>
                  <th>
                    分类
                  </th>
                  <th>
                    申请称号
                  </th>
                  <th>
                    证书
                  </th>
                  <th>
                    申请时间
                  </th>
                  <th>
                    状态
                  </th>
                  <th >
                    操作
                  </th>
                  </thead>
                  <tbody>
                  @foreach($apply as $apply)
                    <tr class="text-center">
                      <td>
                        {{ $loop->iteration }}
                      </td>
                      <td>
                        {{ $apply->user->nickname }}
                      </td>
                      <td>
                        {{ $apply->zone->title }}
                      </td>
                      <td>
                        {{ $apply->rank }}
                      </td>
                      <td>
                        <button type="button" class="btn btn-primary btn-link" data-toggle="modal" data-target="#applyModel">
                            查看
                        </button>

                          <!-- Modal -->
                          <div class="modal fade" id="applyModel" tabindex="-1" role="dialog" aria-labelledby="applyModelLabel" aria-hidden="true">
                            <div class="modal-dialog" role="document">
                              <div class="modal-content">
                                <div class="modal-header">
                                  <h5 class="modal-title" id="applyModelLabel">证书查看</h5>
                                  <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                    <span aria-hidden="true">&times;</span>
                                  </button>
                                </div>
                                <div class="modal-body">
                                    <img src="{{ $apply->certificate }}" class="mx-auto d-block" width="100%" >
                                </div>
                              </div>
                            </div>
                          </div>
                      </td>
                      <td>
                        {{ $apply->apply_time }}
                      </td>
                      <td>
                        @switch($apply->status)
                        @case('0') <span class="badge badge-pill badge-warning">未审核</span> @break
                        @case('1') <span class="badge badge-pill badge-success">已通过</span> @break
                        @case('2') <span class="badge badge-pill badge-danger">未通过</span> @break
                        @endswitch
                      </td>
                      <td class="td-actions">
                            <button onclick="window.location.href = 'apply/{{$apply->id}}?status=1'" type="button" rel="tooltip" class="btn btn-success" {{ $apply->status==0 ?'':'disabled' }} >
                                <i class="material-icons">done</i>
                            </button>
                            <button onclick="window.location.href = 'apply/{{$apply->id}}?status=2'" type="button" rel="tooltip" class="btn btn-danger" {{ $apply->status==0 ?'':'disabled' }} >
                                <i class="material-icons">clear</i>
                            </button>
                      </td>
                    </tr>
                  @endforeach
                  </tbody>
                </table>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
@endsection
